import { getTopCategoryAPI } from '@/apis/category';
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { onBeforeRouteUpdate } from 'vue-router';
export const useCategory = () => {
    const categoryData = ref({})
    const route = useRoute()
    const getCategory = async (id) => {
        categoryData.value = (await getTopCategoryAPI(id)).data
    }
    onBeforeRouteUpdate((to) => {
        getCategory(to.params.id)
    })
    onMounted(() => getCategory(route.params.id))
    return {
        categoryData
    }
}